/**
 * 
 */
package com.jcnet.bizaia.tools;
import android.content.Context;
import android.content.SharedPreferences;

/**
 * @author Administrator
 *
 */
public class DataStorageHelper {

	protected SharedPreferences sp;
	protected SharedPreferences.Editor editor;
	protected Context context;
	
	public DataStorageHelper(Context c, String name) {
		context = c;
		sp = context.getSharedPreferences(name, Context.MODE_PRIVATE);
	//	editor = sp.edit();
	//	editor.apply();
	}

	public void put(String key, String value) {
		editor = sp.edit();
		editor.putString(key, value);
		editor.commit();
	}
	
	public void putInt(String key, int value){
		editor = sp.edit();
		editor.putInt(key,value);
		editor.commit();
		
	}
	
	public int getInt(String key , int value){
		
		return sp.getInt(key, value);
	}
	
	public void putBoolean(String key, Boolean value){
		editor = sp.edit();
		editor.putBoolean(key, value);
		editor.commit();
	}
	public void remove(String... key) {
		editor = sp.edit();
		
		for (int i = 0; i < key.length; i++) {
			editor.remove(key[i]);
		}
		editor.commit();
	}

	public String get(String key) {
		return sp.getString(key, null);
	}
	public String get(String key ,String defaultValue) {
		return sp.getString(key, defaultValue);
	}
	public int getInt(String key) {
		return sp.getInt(key, 0);
	}
	public boolean getBoolean(String key) {
		return sp.getBoolean(key, false);
	}

}
